<template>
	<view class="order">
		<view class="item" v-for="(item, index) in pageList">
			<view class="" @click="order_detail_btn">
				<view class="item_top">
					<span>{{item.createTime}}</span>
					<span>+¥{{item.reward}}</span>
				</view>
				<view class="item_qu">
					<view style="width: 45rpx; height: 45rpx; text-align: center; line-height: 45rpx; background-color: #E40000; color: #fff; border-radius: 50%;">
						取
					</view>
					<view style="margin: 0rpx 20rpx;">
						{{item.barArea}}
					</view>
				</view>
				<view class="item_switch">
					<img style="width: 45rpx; height: 45rpx;" src="@/static/img/switch.png" alt="" >
					<view style="margin: 0rpx 20rpx;">
						相距{{item.distance}}
					</view>
				</view>
				<view class="item_song">
					<view style="width: 45rpx; height: 45rpx; text-align: center; line-height: 45rpx; background-color: #CB9E13; color: #fff; border-radius: 50%;">
						送
					</view>
					<view style="margin: 0rpx 20rpx;">
						{{item.userAddrVO.addr}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { barRiderOrderPage } from '@/api/user.js'
	export default {
		data() {
			return {
				queryParams: {
					pageNum: 1,
					pageSize: 6,
				},
				pageList: [],
				total: 0,
				riderId: null,
			}
		},
		onLoad(options) {
			console.log(options, '=================>options')
			this.riderId = options.riderId
			this.getPage(); 
		},
		onPullDownRefresh() {
			this.queryParams = {
				pageNum: 1,
				pageSize: 6,
			},
			this.getPage();  
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1000)
		},
		onReachBottom() {
			// 判断当前页是否大于等于总页数
			const totalPagestotal = this.total / this.queryParams.pageSize
			if (totalPagestotal <= this.queryParams.pageNum) {
				uni.$u.toast('没有更多数据啦')
			} else {
				this.queryParams.pageNum++;
				this.getPage();   // 每次滑动请求接口，实现上拉加载更多数据
			}
		},
		methods: {
			getPage() {
				barRiderOrderPage({ ...this.queryParams, riderId: this.riderId }).then(res => {
					this.pageList = res.data.list
					this.total = res.data.total
				})
			},
			order_detail_btn() {
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.order{
		height: 97vh;
		padding: 20rpx;
		background-color: #F7F8FA;
		font-size: 26rpx;
		.item{
			margin: 20rpx 0;
			padding: 20rpx;
			background-color: #fff;
			.item_top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 12rpx 0;
			}
			.item_qu{
				display: flex;
				align-items: center;
				padding: 12rpx 0;
			}
			.item_switch{
				display: flex;
				align-items: center;
				padding: 12rpx 0;
			}
			.item_song{
				display: flex;
				align-items: center;
				padding: 12rpx 0;
			}
		}
	}
</style>